package com.arpa.wms.domain.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: Allen chen
 * @Date 2020/9/1
 * @Description:商品类型枚举
 */
public enum GoodsTypeEnum {
    /**
     * 商品类型
     */
    FINISHED_PRODUCTS("1","成品"),
    PREPARED_PRODUCTS("2","半成品"),
    MATERIAL("0","原料"),
    ;

    private final String code;

    private final String desc;

    private static final Map<String, GoodsTypeEnum> ENUM_MAP = new HashMap<>();

    private static final Map<String, GoodsTypeEnum> mapDesc = new HashMap<>();

    static {
        GoodsTypeEnum[] values = GoodsTypeEnum.values();
        int length = values.length;
        for (int i = 0; i < length; i++) {
            GoodsTypeEnum value = values[i];
            ENUM_MAP.put(value.getCode(),value);
            mapDesc.put(value.getDesc(),value);
        }
    }


    GoodsTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static GoodsTypeEnum getEnumByCode(String code){
        return ENUM_MAP.get(code);
    }
    public static GoodsTypeEnum getEnumByDesc(String code){
        return mapDesc.get(code);
    }

    public String getCode() {
        return code;
    }


    public String getDesc() {
        return desc;
    }

}
